package com.aspose.cells;

import java.util.ArrayList;

class zuq {
   byte[] a = new byte[80];

   void a(zuq var1) {
      this.a = new byte[var1.a.length];
      System.arraycopy(var1.a, 0, this.a, 0, this.a.length);
   }

   zuq(int var1) {
      this.a[0] = 6;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.a, 4, 4);
   }

   int a() {
      return com.aspose.cells.b.a.zc.a(this.a, 4);
   }

   int b() {
      return com.aspose.cells.b.a.zc.e(this.a, 8);
   }

   void a(int var1) {
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.a, 8, 2);
   }

   private void g() {
      if ((this.a[8] & 255) == 255) {
         this.a[8] = 0;
         ++this.a[9];
      } else {
         ++this.a[8];
      }

   }

   int c() {
      return com.aspose.cells.b.a.zc.a(this.a, 0) + 4;
   }

   boolean d() {
      return this.c() > 10;
   }

   int e() {
      if (!this.d()) {
         return 0;
      } else {
         byte var1 = 10;
         return (this.a[var1] & 255 & 8) != 0 ? com.aspose.cells.b.a.zc.b(this.a, var1 + 1) : 0;
      }
   }

   Object a(int var1, int var2) {
      int var4 = 1;
      if ((this.a[var2] & 255 & 8) != 0) {
         var4 += 2;
      }

      Object var5 = null;
      switch(this.a[var2] & 255 & 7) {
      case 0:
      default:
         break;
      case 1:
         var5 = com.aspose.cells.b.a.zc.f(this.a, var2 + var4);
         break;
      case 2:
         var5 = zco.a(this.a, var2 + var4);
         break;
      case 3:
         var5 = a((byte)((this.a[var2] & 255 & 240) >> 4));
         break;
      case 4:
         var5 = (this.a[var2] & 255 & 240) != 0;
      }

      return var5;
   }

   zum b(int var1, int var2) {
      int var4 = 1;
      if ((this.a[var2] & 255 & 8) != 0) {
         var4 += 2;
      }

      Object var5 = null;
      switch(this.a[var2] & 255 & 7) {
      case 0:
      default:
         break;
      case 1:
         var5 = com.aspose.cells.b.a.zc.f(this.a, var2 + var4);
         break;
      case 2:
         int var6 = com.aspose.cells.b.a.zc.e(this.a, var2 + var4) & '\uffff';
         if (var6 == 0) {
            var5 = "";
         } else if (this.a[var2 + var4 + 2] == 0) {
            byte[] var7 = new byte[var6 * 2];
            var2 = var2 + var4 + 3;

            for(int var8 = 0; var8 < var6; ++var8) {
               var7[var8 * 2] = this.a[var2 + var8];
            }

            var5 = Encoding.getUnicode().a(var7, 0, var6 * 2);
         } else {
            var5 = Encoding.getUnicode().a(this.a, var2 + var4 + 3, var6 * 2);
         }
         break;
      case 3:
         var5 = a((byte)((this.a[var2] & 255 & 240) >> 4));
         break;
      case 4:
         var5 = (this.a[var2] & 255 & 240) != 0;
      }

      return new zum(var1, var5);
   }

   int a(zfv var1, int var2, short var3, boolean var4, boolean var5) {
      if (var2 < 0) {
         var2 = 10;
         var3 = -1;
      } else {
         --var3;
      }

      int var6 = this.c();
      short var7 = -1;
      int var8 = -1;

      for(int var9 = var2; var2 < var6; var2 = var9) {
         ++var9;
         if ((this.a[var2] & 255 & 8) != 0) {
            var3 = com.aspose.cells.b.a.zc.b(this.a, var2 + 1);
            if (var5 && var3 > var1.a) {
               var1.a = var7;
               return var8;
            }

            var9 += 2;
         } else {
            ++var3;
         }

         switch(this.a[var2] & 255 & 7) {
         case 1:
            if (var3 >= var1.a) {
               return var2;
            }

            if (var5) {
               var8 = var2;
               var7 = var3;
            }

            var9 += 8;
            break;
         case 2:
            if (var3 >= var1.a) {
               return var2;
            }

            if (var5) {
               var8 = var2;
               var7 = var3;
            }

            int var10 = com.aspose.cells.b.a.zc.e(this.a, var9) & '\uffff';
            if (var10 == 0) {
               var9 += 3;
            } else {
               var9 += 2;
               if (this.a[var9] == 0) {
                  ++var9;
                  var9 += var10;
               } else {
                  ++var9;
                  var9 += var10 << 1;
               }
            }
            break;
         case 3:
         case 4:
            if (var3 >= var1.a) {
               return var2;
            }

            if (var5) {
               var8 = var2;
               var7 = var3;
            }
            break;
         default:
            if (var4) {
               if (var5 && var3 == var1.a) {
                  var1.a = var7;
                  return var8;
               }
            } else {
               if (var3 == var1.a) {
                  return var2;
               }

               if (var5) {
                  var7 = var3;
                  var8 = var2;
               }
            }
         }
      }

      if (var5) {
         var1.a = var7;
         return var8;
      } else {
         ++var3;
         var1.a = var3;
         return -1;
      }
   }

   int a(int var1, zfv var2) {
      if ((this.a[var1] & 255 & 8) != 0) {
         var2.a = com.aspose.cells.b.a.zc.b(this.a, var1 + 1);
         return this.a(var1, var1 + 3, var2);
      } else {
         ++var2.a;
         return this.a(var1, var1 + 1, var2);
      }
   }

   private int a(int var1, int var2, zfv var3) {
      switch(this.a[var1] & 255 & 7) {
      case 1:
         var3.c = 1;
         var3.d = com.aspose.cells.b.a.zc.f(this.a, var2);
         return var2 + 8;
      case 2:
         var3.c = 4;
         int var4 = com.aspose.cells.b.a.zc.e(this.a, var2) & '\uffff';
         var2 += 2;
         if (var4 == 0) {
            ++var2;
            var3.d = "";
         } else if (this.a[var2] == 0) {
            byte[] var5 = new byte[var4 << 1];
            ++var2;

            for(int var6 = 0; var6 < var4; ++var6) {
               var5[var6 * 2] = this.a[var2 + var6];
            }

            var3.d = Encoding.getUnicode().a(var5, 0, var4 * 2);
            var2 += var4;
         } else {
            ++var2;
            var3.d = Encoding.getUnicode().a(this.a, var2, var4 << 1);
            var2 += var4 << 1;
         }
         break;
      case 3:
         var3.c = 3;
         var3.d = com.aspose.cells.a.c.zi.a(zsk.b(a((byte)((this.a[var1] & 255 & 240) >> 4))));
         return var2;
      case 4:
         var3.c = 2;
         var3.d = (this.a[var1] & 255 & 240) != 0;
         return var2;
      default:
         var3.c = 0;
         var3.d = null;
      }

      return var2;
   }

   public zun c(int var1, int var2) {
      return new zun(this, var1, var2);
   }

   boolean a(int var1, int[] var2, boolean[] var3) {
      int var4 = 10;
      int var5 = this.c();
      boolean var6 = false;
      int var7 = -1;
      int var8 = -1;
      var2[0] = var5;

      int var10;
      for(var3[0] = false; var4 < var5; var4 += var10) {
         int[] var9 = new int[]{var7};
         var10 = this.a(var4, var9);
         var7 = var9[0];
         if (var7 == var1) {
            var2[0] = var4;
            var3[0] = (this.a[var4] & 255 & 8) == 0;
            return true;
         }

         if (var7 > var1) {
            var2[0] = var4;
            var3[0] = var7 - var8 == 1;
            return false;
         }

         var8 = var7;
      }

      var3[0] = var1 - var8 == 1;
      return false;
   }

   ArrayList f() {
      int var1 = 10;
      int var2 = this.c();
      boolean var3 = false;
      int var4 = -1;

      ArrayList var5;
      int var7;
      for(var5 = new ArrayList(); var1 < var2; var1 += var7) {
         int[] var6 = new int[]{var4};
         var7 = this.a(var1, var6);
         var4 = var6[0];
         com.aspose.cells.b.a.a.ze.a(var5, (Object)this.b(var4, var1));
      }

      return var5;
   }

   double[] d(int var1, int var2) {
      double[] var3 = new double[var2 - var1 + 1];
      int var4 = 10;
      int var5 = this.c();
      boolean var6 = false;

      int var10;
      for(int var7 = -1; var4 < var5; var4 += var10) {
         int[] var8 = new int[]{var7};
         var10 = this.a(var4, var8);
         var7 = var8[0];
         if (var7 > var2) {
            break;
         }

         if (var7 >= var1) {
            Object var9 = this.a(var7, var4);
            if (var9 instanceof Double) {
               var3[var7 - var1] = (Double)var9;
            }
         }
      }

      return var3;
   }

   Object[] e(int var1, int var2) {
      Object[] var3 = new Object[var2 - var1 + 1];
      int var4 = 10;
      int var5 = this.c();
      boolean var6 = false;

      int var9;
      for(int var7 = -1; var4 < var5; var4 += var9) {
         int[] var8 = new int[]{var7};
         var9 = this.a(var4, var8);
         var7 = var8[0];
         if (var7 > var2) {
            break;
         }

         if (var7 >= var1) {
            var3[var7 - var1] = this.a(var7, var4);
         }
      }

      return var3;
   }

   Object b(int var1) {
      byte var2 = 0;
      boolean var3 = false;
      int[] var4 = new int[]{var2};
      boolean[] var5 = new boolean[]{var3};
      boolean var6 = this.a(var1, var4, var5);
      int var7 = var4[0];
      var3 = var5[0];
      return var6 ? this.b(var1, var7).b : null;
   }

   private Object a(Object var1, int[] var2) {
      var2[0] = 0;
      if (var1 == null) {
         return var2[0];
      } else if (var1 instanceof zst) {
         var2[0] = 3;
         return var1;
      } else {
         switch(zamo.a(var1.getClass())) {
         case 3:
            var2[0] = 4;
            break;
         case 9:
            var2[0] = 1;
            var1 = (double)(Integer)var1;
            break;
         case 14:
            var2[0] = 1;
            break;
         case 16:
            var2[0] = 1;
            var1 = CellsHelper.getDoubleFromDateTime((DateTime)var1, false);
            break;
         case 18:
            var2[0] = 2;
            boolean var3 = false;
            boolean[] var4 = new boolean[]{var3};
            zst var5 = zsk.a((String)var1, var4);
            var3 = var4[0];
            if (var3) {
               var1 = var5;
               var2[0] = 3;
            }
         }

         return var1;
      }
   }

   void a(int var1, Object var2) {
      byte var3 = 0;
      boolean var4 = false;
      int var5 = 0;
      int[] var6 = new int[]{var3};
      boolean[] var7 = new boolean[]{var4};
      boolean var8 = this.a(var1, var6, var7);
      int var15 = var6[0];
      var4 = var7[0];
      if (var8) {
         var5 = this.c(var15);
      } else {
         this.a(var1);
      }

      byte var9 = 0;
      int[] var10 = new int[]{var9};
      var2 = this.a(var2, var10);
      int var16 = var10[0];
      int var11 = this.a(var4, var16, var2);
      this.a(var15, var5, var11);
      this.a[var15] = (byte)var16;
      int var12 = 1;
      if (!var4) {
         this.a[var15] = (byte)(this.a[var15] | 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.a, var15 + var12, 2);
         var12 += 2;
      }

      switch(var16) {
      case 0:
      default:
         break;
      case 1:
         System.arraycopy(com.aspose.cells.b.a.zc.a((Double)var2), 0, this.a, var15 + var12, 8);
         break;
      case 2:
         String var13 = (String)var2;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var13.length()), 0, this.a, var15 + var12, 2);
         var12 += 2;
         byte[] var14 = zakq.a(var13);
         if (var14 != null) {
            if (var14.length != var13.length()) {
               this.a[var15 + var12] = 1;
            }

            System.arraycopy(var14, 0, this.a, var15 + var12 + 1, var14.length);
         }
         break;
      case 3:
         this.a[var15] = (byte)(this.a[var15] & 15);
         this.a[var15] |= (byte)((a((zst)var2) & 255) << 4);
         break;
      case 4:
         if ((Boolean)var2) {
            this.a[var15] = (byte)(this.a[var15] | 16);
         } else {
            this.a[var15] = (byte)(this.a[var15] & 15);
         }
      }

   }

   int a(int var1, int[] var2) {
      int var3 = 1;
      if ((this.a[var1] & 255 & 8) != 0) {
         var2[0] = com.aspose.cells.b.a.zc.b(this.a, var1 + var3);
         var3 += 2;
      } else {
         ++var2[0];
      }

      switch(this.a[var1] & 255 & 7) {
      case 0:
      case 3:
      case 4:
      default:
         break;
      case 1:
         var3 += 8;
         break;
      case 2:
         int var4 = com.aspose.cells.b.a.zc.e(this.a, var1 + var3) & '\uffff';
         if (this.a[var1 + var3 + 2] == 1) {
            var4 *= 2;
         }

         var3 += 3 + var4;
      }

      return var3;
   }

   int c(int var1) {
      int var2 = 1;
      if ((this.a[var1] & 255 & 8) != 0) {
         var2 += 2;
      }

      switch(this.a[var1] & 255 & 7) {
      case 0:
      case 3:
      case 4:
      default:
         break;
      case 1:
         var2 += 8;
         break;
      case 2:
         int var3 = com.aspose.cells.b.a.zc.e(this.a, var1 + var2) & '\uffff';
         if (this.a[var1 + var2 + 2] == 1) {
            var3 *= 2;
         }

         var2 += 3 + var3;
      }

      return var2;
   }

   int a(boolean var1, int var2, Object var3) {
      int var4 = 1;
      if (!var1) {
         var4 += 2;
      }

      switch(var2) {
      case 0:
      case 3:
      case 4:
      default:
         break;
      case 1:
         var4 += 8;
         break;
      case 2:
         byte[] var5 = zakq.a((String)var3);
         var4 += 3;
         if (var5 != null) {
            var4 += var5.length;
         }
      }

      return var4;
   }

   void a(int var1, int var2, int var3, byte[] var4, int var5) {
      int var6 = 1;
      if (var2 - var1 != 1) {
         var6 += 2;
      }

      int var7;
      switch(var3) {
      case 0:
      case 3:
      case 4:
      default:
         break;
      case 1:
         var6 += 8;
         break;
      case 2:
         var7 = com.aspose.cells.b.a.zc.e(var4, var5) & '\uffff';
         if (var4[var5 + 2] == 0) {
            var6 += 3 + var7;
         } else {
            var6 += 3 + var7 + var7;
         }
      }

      var7 = this.c();
      this.a(var7, 0, var6);
      this.a[var7] = (byte)var3;
      int var8 = 1;
      if (var2 - var1 != 1) {
         this.a[var7] = (byte)(this.a[var7] | 8);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, this.a, var7 + var8, 2);
         this.a(var2);
         var8 += 2;
      } else if (var2 != 0) {
         this.g();
      }

      switch(var3) {
      case 0:
      default:
         break;
      case 1:
         System.arraycopy(var4, var5, this.a, var7 + var8, 8);
         break;
      case 2:
         int var9 = com.aspose.cells.b.a.zc.e(var4, var5) & '\uffff';
         if (var4[var5 + 2] == 0) {
            var9 += 3;
         } else {
            var9 += 3 + var9;
         }

         System.arraycopy(var4, var5, this.a, var7 + var8, var9);
         break;
      case 3:
         this.a[var7] |= (byte)((a(zsk.a(var4[var5])) & 255) << 4);
         break;
      case 4:
         if (var4[var5] == 1) {
            this.a[var7] = (byte)(this.a[var7] | 16);
         }
      }

   }

   void a(int var1, int var2, int var3) {
      int var4 = var3 - var2;
      if (var4 != 0) {
         int var5 = this.c();
         int var6 = var5 + var4;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6 - 4), 0, this.a, 0, 4);
         byte[] var7;
         int var8;
         if (var6 > this.a.length) {
            if (var6 < this.a.length * 2) {
               var6 = this.a.length * 2;
            }

            var7 = new byte[var6];
            var8 = var1 + var2;
            System.arraycopy(this.a, 0, var7, 0, var1);
            if (var8 < var5) {
               System.arraycopy(this.a, var8, var7, var1 + var3, var5 - var8);
            }

            this.a = var7;
         } else if (var6 > 80 && var6 < this.a.length / 3) {
            var6 = this.a.length / 2;
            var7 = new byte[var6];
            var8 = var1 + var2;
            System.arraycopy(this.a, 0, var7, 0, var1);
            if (var8 < var5) {
               System.arraycopy(this.a, var8, var7, var1 + var3, var5 - var8);
            }

            this.a = var7;
         } else {
            System.arraycopy(this.a, var1 + var2, this.a, var1 + var3, var5 - (var1 + var2));
         }

      }
   }

   static byte a(zst var0) {
      switch(null.a[var0.ordinal()]) {
      case 1:
         return 0;
      case 2:
         return 1;
      case 3:
         return 2;
      case 4:
         return 3;
      case 5:
         return 4;
      case 6:
         return 5;
      case 7:
         return 6;
      default:
         return 0;
      }
   }

   static zst a(byte var0) {
      switch(var0) {
      case 0:
         return zst.e;
      case 1:
         return zst.a;
      case 2:
         return zst.i;
      case 3:
         return zst.g;
      case 4:
         return zst.d;
      case 5:
         return zst.f;
      case 6:
         return zst.c;
      default:
         return zst.c;
      }
   }
}
